<?php
/***************************************************************************
*	Filename	:	class.core.php
*	Copyright	:	(C) 2013  Brisingr Group.
*
*	This program is free software: you can redistribute it and/or modify
*	it under the terms of the GNU General Public License as published by
*	the Free Software Foundation, either version 3 of the License, or
*	(at your option) any later version.
*
*	This program is distributed in the hope that it will be useful,
*	but WITHOUT ANY WARRANTY; without even the implied warranty of
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*	GNU General Public License for more details.
*
*	You should have received a copy of the GNU General Public License
*	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*
****************************************************************************/
/***************************************************************************
Funkcje które tutaj się znajdują będą wykorzystywane przez całą stronę.
Każda funkcja będzie posiadać opis jej działania oraz zastosowanie.
#Krzychu
****************************************************************************/	
	
Class Core 
{
	public $root_dir;
	public $Ptr_versions_file =  'versions.ini';
	public $Ptr_sett_file = 'siete.settings';
	public $core_dir = 'core/';
	public $sett_dir = 'sett';
	public $templ_dir = 'templ';
	
	public $cached_settings = array();
	
	public $settings = array();
	
		function __construct($main_dir)
		{
			$this->root_dir = $main_dir;
		}
		// end. __construct;

		
/*
	get_verisons
	Pobiera versje plików i zwraca jako tablicę.
	W przypadku błędu otwarcia zwraca fałsz.
	* Wykorzystane zostanie w skrypcie aktualizującym.
*/
	public function get_verisons()
		{
			
			$pobierz_dane  = @file(($this->root_dir.$this->core_dir.$this->Ptr_versions_file));
			$nowa_baza = array();
			$count = count($pobierz_dane);
			if($count == 0) return false;

			
			for( $i= 0; $i < $count ; $i++ )
			{
				if(!empty($pobierz_dane[$i]))
				{
					$rozdzielone = explode('=',$pobierz_dane[$i]);
					$nowa_baza[$rozdzielone[0]] = trim($rozdzielone[1]);
				}
				
			}
			unset($count,$pobierz_dane);
			return $nowa_baza;
			
		}
		
		
/*
	



*/
	public function Load_Settings()
	{
			$sitefile = $this->root_dir.$this->sett_dir.$this->Ptr_sett_file;
			if(file_exists($sitefile))
			{
				$this->cached_settings = unserialize(file_get_contents($sitefile));
			}
			else
			{
				// create default vars.
				$default = array(
					'site_title' => 'Default Site Name',
					'site_descr' => 'Default Site Desc',
					'is_online'  => true,
					'cur_templ'  => 'default',
					
				);
			}
		
	}
}


?>